import java.util.*;

/**
 * @author LKQ
 * @date 2022/4/14 16:22
 * @description 优先队列排序，画蛇添足
 */
public class Solution {
    public static void main(String[] args) {

    }
    public String kthLargestNumber(String[] nums, int k) {
        PriorityQueue<String> pq = new PriorityQueue<>(new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                if (o1.length() != o2.length()) {
                    return o1.length() - o2.length();
                }else {
                    int n = o1.length();
                    for (int i = 0; i < n; i++) {
                        char c1 = o1.charAt(i);
                        char c2 = o2.charAt(i);
                        if (c1 != c2) {
                            return (c1 - '0' - (c2 - '0'));
                        }
                    }
                    return 0;
                }
            }
        });
        for (String a: nums) {
            pq.add(a);
        }
        if (k != nums.length) {
            for (int i = 0; i < nums.length - k; i++) {
                pq.poll();
            }
        }
        return pq.peek();
    }
}
